<include file="Public/header" />
	<body>
			<div class="mui-content">
				<header class="mui-bar mui-bar-nav pub_head">
			        <a class="mui-action-back mui-icon mui-pull-left iconfont icon-left" href="javascript:history.go(-1)"></a>
			        <h1 class="mui-title">在线报名</h1>
			        <a class="mui-icon mui-pull-right iconfont icon-house1" style="font-size:26px;padding-top:0.5rem;" href='/'></a>
			    </header>
				<form class="enrol_list mTop"  method="post">
					<div class="enrol_list_tit">
						在线报名
					</div>
					<div class="enrol_list_cont">
						<p>姓名<em>*</em></p>
						<div class="enrol_cont">
							<input type="text" placeholder="请输入真实姓名" name="user_name" id="user_name" value="" />
							<i class="iconfont icon-yonghuming"></i>
						</div>
						
						<p>身份证号<em>*</em></p>
						<div class="enrol_cont">
							<input type="text" placeholder="请输入18位身份证号" name="id_card" id="id_card" value="" />
							<i class="iconfont icon-shenfenzheng"></i>
						</div>
						
						<p>所选班型<em>*</em></p>
						<div class="enrol_cont_before">
							<i class="iconfont icon-banjibianhao"></i>
                                                        <select name="class" id="class_type" onchange="getClass()">
                                                            <option value="普通班">请选择班型</option>
								<foreach name="class_type" item="vo">
									<option value="{$vo.id}">{$vo.name}</option>
                                                                </foreach>
							</select>
						</div><br />
						<p>所选班级<em>*</em></p>
						<div class="enrol_cont_before">
							<i class="iconfont icon-banjibianhao"></i>
							<select name="class" id="class" onchange="getClassPrice()">
							 <option value="普通班">请选择班级</option>
							</select>
						</div><br />
						<p>费用<i>*</i></p>
						<div class="enrol_cont">
							<input type="text" id='price' name='money' value="" disabled >
                                                        <input type="hidden" id='price_p' name='money' value="" >
                                                        <input type="hidden" id='sc_id' name='money' value="{$sc_id}" >
                                                <i class="iconfont icon-gouwuche01"></i>
						</div>
                        
						<p>电话<i>*</i></p>
						<div class="enrol_cont">
							<input type="text" placeholder="请输入电话" value="" name="phone" id="phone" />
							<i class="iconfont icon-dianhua2"></i>
						</div>
					</div>
					<div class="enrol_btn">
						<button type="button" id="submit" class="btn submit" onclick="putApply()">报名</button>
						<button type="reset" class="btn reset">清空</button>
					</div>
				</form>
			</div>

	</body>
        <script>
             //获取班级
            function getClass(){
                var id = $('#class_type').val();
                $.ajax({
                    url:"{:U('User/getClass')}",
                    type:"post",
                    data:{id:id},
                    success:function(w){
                        $('#class').html(w);
                    }
                })
            }
            //获取报名费用
            function getClassPrice(){
                var id = $('#class').val();
                $.ajax({
                    url:"{:U('User/getClassPrice')}",
                    type:"post",
                    data:{id:id},
                    success:function(w){
                       var data = eval('('+w+')');
                       $('#price').val('￥'+data.price);
                       $('#price_p').val(data.price);
                    }
                })
            }
            //报名
            function putApply(){
                var  name = $('#user_name').val();
                var  id_card = $('#id_card').val();
                var  class_id = $('#class').val();
                var  price = $('#price_p').val();
                var  phone = $('#phone').val();
                var  sc_id = $('#sc_id').val();
                if(name == '' || id_card=='' || class_id == '' || price == '' || phone ==''){
                    layer.open({
                        content: '请完善报名信息后提交'
                        ,skin: 'msg'
                        ,time: 2 //2秒后自动关闭
                    });
                    return false;
                }
                layer.open({
                    type: 2
                    ,content: '报名中'
                    ,shadeClose:false
                 });
                $.ajax({
                    url:"{:U('User/putApply')}",
                    type:"post",
                    data:{name:name,id_card:id_card,class_id:class_id,price:price,phone:phone,sc_id:sc_id},
                    success:function(w){
                       layer.closeAll();
                       if(w == 1){
                           layer.open({
                                type: 2
                                ,content: '报名中成功，正在跳往支付...'
                                
                            });
                       }else if(w==0){
                           layer.open({
                                content: '报名失败'
                                ,skin: 'msg'
                                ,time: 2 //2秒后自动关闭
                            });
                       }else if(w==4){
                           layer.open({
                                content: '已经报过名，不能重复报名'
                                ,skin: 'msg'
                                ,time: 2 //2秒后自动关闭
                            });
                       }else{
                           layer.open({
                                content: '请完善报名信息后提交'
                                ,skin: 'msg'
                                ,time: 2 //2秒后自动关闭
                            });
                       }
                    }
                })
            }
        </script>
</html>